<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Running Ibator With Ant</title>
  <link type="text/css" rel="stylesheet" href="../ibator.css"/>
</head>
<body>

<div class="menuNav">
  <p>
    <a href="../index.html" target="_top">Show Menu</a>
    <a href="runningWithAnt.html" target="_top">Hide Menu</a>
  </p>
</div>

<h1>Running Ibator With Ant</h1>
<p>Ibator includes a simple Ant task.  The task must be defined in your
  build.xml file, and the task has three parameters.  Here is an example
  build.xml file:</p>
<pre>
   &lt;project default="genfiles" basedir="."&gt;
     &lt;property name="generated.source.dir" value="${basedir}" /&gt;

     &lt;target name="genfiles" description="Generate the files"&gt;
       &lt;taskdef name="ibator"
                classname="org.apache.ibatis.ibator.ant.IbatorAntTask"
                classpath="ibator.jar" /&gt;
       &lt;ibator overwrite="true" configfile="ibatorConfig.xml" verbose="false" &gt;
         &lt;propertyset&gt;
           &lt;propertyref name="generated.source.dir"/&gt;
         &lt;/propertyset&gt;
       &lt;/ibator&gt;
     &lt;/target&gt;
   &lt;/project&gt;
</pre>

<p>Ibator task attributes are as follows:</p>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
  <th>Attribute</th>
  <th>Value</th>
</tr>
<tr>
  <td>configfile (required)</td>
  <td>Specifies the name of the configuration file.</td>
</tr>
<tr>
  <td>overwrite (optional)</td>
  <td>If "true", "yes", etc., then existing Java files will be overwritten if an existing Java
      file if found with the same name as a generated file.  If "false", "no", etc., and a
      Java file already exists with the same name as a generated file, then Ibator
      will write the newly generated Java file to the proper directory with a
      unique name (e.g. MyClass.java.1, MyClass.java.2, etc.).
      <b>Important: Ibator will always merge and overwrite XML files.</b></td>
</tr>
<tr>
  <td>contextids (optional)</td>
  <td>If specified, then this is a comma delimited list of contexts to use in
      the current run of Ibator.  Any id specified in the list must exactly
      match the value of the <code>id</code> attribute of an
      &lt;ibatorContext&gt; configuration element.  Only ids specified
      in this list will be active for this run of Ibator.  If this argument
      is not specified, then all contexts will be active.</td>
</tr>
<tr>
  <td>tables (optional)</td>
  <td>If specified, then this is a comma delimited list of tables to use in
      the current run of Ibator.  Any table specified in the list must exactly
      match the fully qualified table name specified in a
      &lt;table&gt; configuration element.  Only tables specified
      in this list will be active for this run of Ibator.  If this argument
      is not specified, then all tables will be active.
      Specify table names as: <br/><br/>
      <code>table</code><br/>
      <code>schema.table</code><br/>
      <code>catalog..table</code><br/>
      etc.</td>
</tr>
<tr>
  <td>verbose (optional)</td>
  <td>If "true", "yes", etc., then Ibator will log progress messages to the
      ant console (if Ant is running in verbose mode).  The default is "false".</td>
</tr>
</table>

<p>Notes:</p>
<ul>
  <li>The classpath on the &lt;taskdef&gt; is used to tell Ant where the Ibator JAR file
     is.  This is optional if you add Ibator to the Ant classpath in one
     of the other ways described in the Ant manual</li>
   <li>The name of the task can be anything you desire, "ibator" is
     simply an example</li>
   <li>The task supports an optional nested <code>&lt;propertyset&gt;</code> element which
       is the standard Ant property set type.  This can be used to pass parameters into
       a configuration file.  For example, the above property
       <code>generated.source.dir</code> can be
       accessed in the Ibator configuration file with the escape sequence
       <code>${generated.source.dir}</code>
   </li>
   <li>If a property is specified in the configuration file and is not resolved,
       then the escaped property string will be passed "as is" into the generated code.
   </li>
</ul>
</body>
</html>